package com.sunway.netty.secondexample;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

public class NettyClient {
	public static void main(String[] args) throws Exception{
		EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
		try {
			Bootstrap bootStrap = new Bootstrap();
			bootStrap.group(eventLoopGroup)
					.channel(NioSocketChannel.class)
					.handler(new ClientInitializer());
			
			ChannelFuture channelFuture = bootStrap.connect("localhost", 8899).sync();
			channelFuture.channel().closeFuture().sync();
		} finally {
			eventLoopGroup.shutdownGracefully();
		}
	}
}
